package com.russell.pms.webapp.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.russell.pms.model.Maintenance;
import com.russell.pms.service.MaintenanceService;
import com.russell.pms.service.PropertyService;
import com.russell.pms.webapp.bean.StatusMessage;

@Controller
public class MaintenanceController extends BaseController	 {

	@Autowired
	private MaintenanceService maintenanceService;
	
	
	@RequestMapping(method = RequestMethod.POST, value = "/maintenance", headers = "Accept=application/xml, application/json")
	@ResponseBody
	public ResponseEntity<StatusMessage> saveMaintenance(@RequestBody Maintenance maintenance) {
		maintenanceService.saveMaintenance(maintenance);

		StatusMessage sm = new StatusMessage();
		sm.setStatus(HttpStatus.CREATED.value());
		sm.setMessage("Accepted " + maintenance.getId());
		return new ResponseEntity<StatusMessage>(sm, HttpStatus.CREATED);
	}

	public void setMaintenanceService(MaintenanceService maintenanceService) {
		this.maintenanceService = maintenanceService;
	}

}
